home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / stdio / c / fclose next >
Text File  |  1996-11-09  |  966b  |  46 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/stdio/c/RCS/fclose,v $
  4.  * $Date: 1996/05/06 09:01:34 $
  5.  * $Revision: 1.2 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: fclose,v $
  10.  * Revision 1.2  1996/05/06 09:01:34  unixlib
  11.  * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
  12.  * Saved for 3.7a release.
  13.  *
  14.  * Revision 1.1  1996/04/19 21:32:42  simon
  15.  * Initial revision
  16.  *
  17.  ***************************************************************************/
  18.  
  19. static const char rcs_id[] = "$Id: fclose,v 1.2 1996/05/06 09:01:34 unixlib Rel $";
  20.  
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include <unistd.h>
  24. #include <fcntl.h>
  25.  
  26. __STDIOLIB__
  27.  
  28. int
  29. fclose (register FILE * f)
  30. {
  31.   if (fflush (f))
  32.     return (-1);
  33.  
  34.   if (f->i_base)
  35.     free (f->i_base);
  36.   if (f->o_base)
  37.     free (f->o_base);
  38.  
  39.   if (close (f->fd))
  40.     return (-1);
  41.  
  42.   f->flag = 0;
  43.  
  44.   return (0);
  45. }
  46.